Skip to content

Conversation

@TonyKim9401 TonyKim9401 self-assigned this Aug 18, 2024
@TonyKim9401 TonyKim9401 marked this pull request as ready for review August 18, 2024 02:48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.

통과는 되었어도 문제의 출제 의도에서 벗어난 풀이인 것 같습니다. : )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하핫.... 출제 의도대로 풀려면 어떻게 하는게 좋을지 조금 더 구체적인 조언 부탁드려도 괜찮을까요?

Copy link
Contributor

@dev-jonghoonpark dev-jonghoonpark Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 작성해주신 코드는 인코딩 결과가 독립적이지 않습니다.

메모리(Map)를 거쳐 encode/decode를 진행하도록 구현되어있는데
네트워크를 통해서 진행될 경우에는 이런식으로 공유되는 메모리를 사용할 수 없습니다.

encode에서는 원본 문자열의 내용이 복원될 수 있는 형태로 가공해야 하고,
decode에서는 가공된 문자열을 원본 문자열로 복구할 수 있어야 합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀주신 대로 공유 메모리를 사용하지 않고 각 메소드 단위에서 처리할 수 있도록 수정했습니다!
리뷰 무척이나 감사 드립니다!! 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요.
풀이 잘 보았습니다 : )

해당 방법에는 str이 " " 와 같이 공백일경우 통과되지 못하는 케이스가 발생됩니다.
예시 인풋은 다음과 같습니다. List.of(" ", " ", " ")
이렇게 인풋이 들어오면 아웃풋으로는 빈 list 가 나오게 되니 원본과 차이가 발생되게 됩니다.

이 문제는 공백이 아닌 다른 문자로 split을 시도하여도 이슈가 발생됩니다.
따라서 약간의 추가 구현이 필요합니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dev-jonghoonpark 님, 피드백이 너무 좋네여! 🫰
@TonyKim9401 님, 그래도 명색이 리트코드 Medium 난이도 문제인데, 너무 과소평가하신 게 아닐까요? 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaleSeo @dev-jonghoonpark @taekwon-dev
해당 문제 피드백 반영하여 다시 풀었습니다!
막막했었는데 좋은 피드백 주셔서 너무나도 감사합니다 ㅎㅎ!! 👍

@TonyKim9401 TonyKim9401 requested a review from leokim0922 August 19, 2024 00:30
// space complexity: O(n)
int[] output = new int[n+1];
int num = 0;
while (num <= n) output[num] = Integer.bitCount(num++);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integer.bitCount 

오호, 이런 게 있었군요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 숫자의 bit에서 1의 갯수를 구해주는 내장 함수입니다ㅎㅎ
잘 쓰시면 도움 되실꺼에요. 시간 복잡도는 O(1) 입니다!

@TonyKim9401 TonyKim9401 force-pushed the main branch 4 times, most recently from c1f9078 to fd3455a Compare August 24, 2024 05:01
@TonyKim9401 TonyKim9401 removed the java label Aug 24, 2024
@TonyKim9401 TonyKim9401 merged commit a85fe39 into DaleStudy:main Aug 24, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

5 participants